//
//  GQHRoleController.m
//  Xanthium
//
//  Created by GuanQinghao on 22/02/2018.
//  Copyright © 2018 GuanQinghao. All rights reserved.
//

#pragma mark Macro
#import "GQHHeader.h"

#pragma mark Model

#pragma mark Object

#pragma mark View
#import "GQHRoleView.h"

#pragma mark Controller
#import "GQHRoleController.h"
#import "GQHTabBarController.h"
#import "GQHServiceWebController.h"

#pragma mark CocoaPods

#pragma mark ----------Header End----------

@interface GQHRoleController () <GQHRoleViewDelegate> {
    
#pragma mark Data
    
#pragma mark View
    /// 自定义根视图
    GQHRoleView *rootView;
}

@end


@implementation GQHRoleController

#pragma mark --Lifecycle
- (void)loadView {
    DLog();
    
    rootView = [[GQHRoleView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    rootView.qh_delegate = self;
    self.view = rootView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    DLog();
    
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    DLog();
    
    self.qh_leftButton.hidden = YES;
    self.qh_titleLabel.text = @"选择角色";
    self.qh_navigationBar.backgroundColor = kAppRedColor;
    self.automaticallyAdjustsScrollViewInsets = NO;
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    DLog();
}

#pragma mark --Delegate
- (void)qh_selectedRowWithTableView:(UITableView *)tableView atIndexPath:(NSIndexPath *)indexPath {
    
    switch (indexPath.row) {
        case 0: {
            
            // 我是货主 01无车承运人  02货主  03司机  04物流企业
            [[NSUserDefaults standardUserDefaults] setValue:USER_TYPE_O forKey:USER_TYPE];
            [[NSUserDefaults standardUserDefaults] synchronize];
            GQHTabBarController *tabBarController = [[GQHTabBarController alloc] init];
            [[UIApplication sharedApplication] keyWindow].rootViewController = tabBarController;
        }
            break;
        case 1: {
            
            // 我是司机
            [[NSUserDefaults standardUserDefaults] setValue:USER_TYPE_D forKey:USER_TYPE];
            [[NSUserDefaults standardUserDefaults] synchronize];
            GQHTabBarController *tabBarController = [[GQHTabBarController alloc] init];
            [[UIApplication sharedApplication] keyWindow].rootViewController = tabBarController;
        }
            break;
        case 2: {
            
            // 我是物流企业
            [[NSUserDefaults standardUserDefaults] setValue:USER_TYPE_E forKey:USER_TYPE];
            [[NSUserDefaults standardUserDefaults] synchronize];
            GQHTabBarController *tabBarController = [[GQHTabBarController alloc] init];
            [[UIApplication sharedApplication] keyWindow].rootViewController = tabBarController;
        }
            break;
        default:
            break;
    }
}

- (void)qh_clickedShortcutButton:(UIButton *)sender {
    
    switch (sender.tag) {
        case 200: {
            
            // 油卡充值
            
        }
            break;
        case 201: {
            
            // ETC
            
        }
            break;
        case 202: {
            
            // 保险
            
        }
            break;
        case 203: {
            
            // 途途行
            GQHServiceWebController *webController = [[GQHServiceWebController alloc] init];
            webController.qh_navCaptionString = @"途途行";
            webController.qh_URLString = @"http://www.hao123.com";
            [self.navigationController pushViewController:webController animated:YES];
        }
            break;
        default:
            break;
    }
}

#pragma mark --TargetMethod

#pragma mark --PrivateMethod

#pragma mark --Setter

#pragma mark --Getter

#pragma mark --View

@end
